import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;
// 复训记录管理

// 页面内容 树
export function getPage(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    personnelId: 0,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize
  }
  return request({
    url: '/getCertrecordPage',
    method: 'post',
    data: data
  })
}

// 复训记录 数据列表
export function listData(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
    keywords: queryParams.keywords,
    personnelId: queryParams.personnelId, //人员 id
    deptId: queryParams.deptId, //所属部门 id
    category: queryParams.category, //证书类别 id
    startTime: queryParams.startTime,
    endTime: queryParams.endTime
  }
  return request({
    url: '/getCertrecordList',
    method: 'post',
    data: data
  })
}
// 复训记录 数据添加
export function addData(val) {
  const data = {
    projectContent:{
      ascriptionId: store.state.userInfo.ascriptionId, //机构 id
      certCode: val.certCode, //证书编号
      personnelId: val.personnelId, //持证人id
      personnelName: val.personnelName, //持证人
      certName: val.certName, //证书名称
      categoryId: val.categoryId, //证书类别
      categoryVal: val.categoryVal, //证书类别的文字值
      startTime: val.startTime, //发证日期
      endTime: val.endTime, //到期日期
      lssuingAuthority: val.lssuingAuthority, //发证机关
      certPic: val.certPic, //复训图片  多个图片之间用 , 隔开
      retrainTime: val.retrainTime, //复训日期
      publisherId: val.publisherId, //添加人id
      publisher: val.publisher, //添加人
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/addCertrecord',
    method: 'post',
    data: data
  })
}

// 复训记录 获取单条数据
export function getData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getCertrecordData',
    method: 'post',
    data: data
  })
}

// 复训记录 数据修改
export function updateData(val) {
  const data = {
    projectContent:{
      theid: val.theid, //id
      certCode: val.certCode, //证书编号
      personnelId: val.personnelId, //持证人id
      personnelName: val.personnelName, //持证人
      certName: val.certName, //证书名称
      categoryId: val.categoryId, //证书类别
      categoryVal: val.categoryVal, //证书类别的文字值
      startTime: val.startTime, //发证日期
      endTime: val.endTime, //到期日期
      lssuingAuthority: val.lssuingAuthority, //发证机关
      certPic: val.certPic, //复训图片  多个图片之间用 , 隔开
      retrainTime: val.retrainTime, //复训日期
      publisherId: val.publisherId, //添加人id
      publisher: val.publisher, //添加人
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/updateCertrecord',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delCertrecord',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultiData(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleCertrecord',
    method: 'post',
    data: data
  })
}

// 下拉框
export function getSelect() {
    const data = {
      ascriptionId: store.state.userInfo.ascriptionId,
    }
    return request({
      url: '/getCertrecordComboBox',
      method: 'post',
      data: data
    })
}